<template>
  <div>
    1
    <!-- 可以把组件提前下载出来,会保存值 -->
    <keep-alive>
      <component :is="Com"></component>
    </keep-alive>
    <component :is="Com"></component>
    <!-- 通过使用路由中传送的值来判断这个盒子是否显示 -->
    <div v-if="$route.meta.bool">1</div>
    <button @click="gaibian">改变</button>
  </div>
</template>
<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}

.fade-enter,
.fade-leave-to {
  opacity: 0;
}

.bounce-enter-active {
  animation: bounce-in 0.5s;
}

.bounce-leave-active {
  animation: bounce-in 0.5s reverse;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

* {
  margin: 0;
  padding: 0;
  font-size: 0.16rem;
}
</style>
<script>
import A from "./kepa.vue";
import B from "./kepb.vue";
export default {
  components: {
    A,
    B,
  },
  data() {
    return {
      Com: "B",
      n: 0,
    };
  },
  methods: {
    gaibian() {
      this.n++;
      if (this.n % 2 == 1) {
        this.Com = "A";
      } else {
        this.Com = "B";
      }
    },
  },
};
</script>
